/**
 * Copyright (C), 2012-2018, 联奕科技有限公司
 * FileName: ValidateCodeBeanConfig
 * Author:   石贵武
 * Date:     2018\3\9 0009 15:34
 * Description: 配置类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhoudongxiu.security.core.vaildators.config;

import com.zhoudongxiu.security.core.properties.SecurityProperties;
import com.zhoudongxiu.security.core.sms.DufaultSmsCodeSender;
import com.zhoudongxiu.security.core.sms.SmsCodeSender;
import com.zhoudongxiu.security.core.vaildators.generator.ImageCodeGenerator;
import com.zhoudongxiu.security.core.vaildators.generator.ValidateCodeGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 〈一句话功能简述〉<br> 
 * 〈配置类〉
 *
 * @author 石贵武
 * @create 2018\3\9 0009
 * @since 1.0.0
 */
@Configuration
public class ValidateCodeBeanConfig {

    @Autowired
    private SecurityProperties securityProperties;

    @Bean
    @ConditionalOnMissingBean(name = "imageCodeGenerator")
    public ValidateCodeGenerator validateCodeGenerator() {
        ImageCodeGenerator imageCodeGenerator = new ImageCodeGenerator();
        imageCodeGenerator.setSecurityProperties(securityProperties);
        return imageCodeGenerator;
    }

    @Bean
    @ConditionalOnMissingBean(name = "smsCodeSender")
    public SmsCodeSender smsCodeSender() {

        return new DufaultSmsCodeSender();
    }
}